package com.ssm.helong.shop.service.impl;

import com.ssm.helong.shop.Dao.ShoppingCarDao;
import com.ssm.helong.shop.entity.ShoppingCar;
import com.ssm.helong.shop.service.ShoppingCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ShoppingCarServiceImpl implements ShoppingCarService {
    @Autowired
    private ShoppingCarDao shoppingCarDao;

    //查询某用户购物车信息
    @Override
    public List findusercar(Integer userId) {
        List userCarList = shoppingCarDao.findusercar(userId);
        return userCarList;
    }

    //添加购物车
    public int addshops(ShoppingCar shoppingCar) {
        return shoppingCarDao.addshops(shoppingCar);
    }

    //移除购物车
    @Override
    public int getdelete(Integer id) {
        return shoppingCarDao.getdelete(id);
    }

    //修改购物车商品的数量
    @Override
    public int updateNum(ShoppingCar shoppingCar) {
        return shoppingCarDao.updateNum(shoppingCar);
    }

    //购物车总价价格
    @Override
    public int totalvalue(Integer userId) {
        int sum = shoppingCarDao.totalvalue(userId);
        return sum;
    }

    //查询某个用户购物车中选中的商品总价格（选取某些）
    @Override
    public int selectShops(Integer userId, Integer goodsId[]) {
        int sum = shoppingCarDao.selectShops(userId, goodsId);
        return sum;
    }
}
